package com.xzh.homeliving.commodity.entity;


import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.xzh.common.valid.EnumValidate;
import com.xzh.common.valid.SaveGroup;
import com.xzh.common.valid.UpdateGroup;
import com.xzh.common.valid.UpdateIsShowGroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;
import java.io.Serializable;

/**
 * 家居品牌
 * 
 * @author xzh
 * @email ranpis02@qq.com
 * @date 2024-01-19 21:41:35
 */
@Data
@TableName("commodity_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * id
	 */
	@TableId
	@NotNull(message = "修改时要求指定id", groups = {UpdateGroup.class, UpdateIsShowGroup.class})
	@Null(message = "添加时不需指定id", groups = {SaveGroup.class})
	private Long id;
	/**
	 * 品牌名
	 */
	@NotBlank(message = "品牌名不能为空", groups = {SaveGroup.class, UpdateGroup.class})
	private String name;
	/**
	 * logo
	 */
	@NotBlank(message = "logo不能为空", groups = {SaveGroup.class})
	@URL(message = "logo不是一个合法的URL", groups = {SaveGroup.class, UpdateGroup.class})
	private String logo;
	/**
	 * 说明
	 * 注意：对于 Integer 类型，我们使用 @NotBlank 注解
	 */
	@NotBlank(message = "描述不能为空", groups = {SaveGroup.class})
	private String description;
	/**
	 * 显示
	 */
	@NotNull(message = "显示不能为空", groups = {SaveGroup.class, UpdateIsShowGroup.class})
	@EnumValidate(values = {0, 1}, message = "显示状态值必须为0或者1", groups = {SaveGroup.class, UpdateGroup.class, UpdateIsShowGroup.class})
	private Integer isshow;
	/**
	 * 检索首字母
	 */
	@NotBlank(message = "检索首字母不能为空", groups = {SaveGroup.class})
	@Pattern(regexp = "^[a-zA-Z]$", message = "检索首字母必须为英文字母", groups = {SaveGroup.class, UpdateGroup.class})
	private String firstLetter;
	/**
	 * 排序
	 */
	@NotNull(message = "排序值不能为0", groups = {SaveGroup.class})
	@Min(value = 0, message = "排序值要求大于等于0", groups = {SaveGroup.class, UpdateGroup.class})
	private Integer sort;
}
